<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>安装 | Manor Farm Mysql</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/manor-farm-mysql/pgmanor_mysql.svg">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">
    <script language="javascript" type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="/manor-farm-mysql/js/MouseClickEffect.js"></script>
    <script language="javascript" type="text/javascript" src="/manor-farm-mysql/js/pgmanor-self.js"></script>
    <meta name="description" content="Mysql学习手册">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/manor-farm-mysql/assets/css/0.styles.7bfce8db.css" as="style"><link rel="preload" href="/manor-farm-mysql/assets/js/app.bbd54b43.js" as="script"><link rel="preload" href="/manor-farm-mysql/assets/js/3.33fa8ee0.js" as="script"><link rel="preload" href="/manor-farm-mysql/assets/js/1.e501e4e7.js" as="script"><link rel="preload" href="/manor-farm-mysql/assets/js/32.b62e21d8.js" as="script"><link rel="preload" href="/manor-farm-mysql/assets/js/8.73e907b5.js" as="script"><link rel="prefetch" href="/manor-farm-mysql/assets/js/10.31e485b8.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/11.bd87e4cf.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/12.0fe1282f.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/13.f1de335a.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/14.4a84a4ee.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/15.bc190a07.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/16.3f42a3ab.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/17.f1cad67c.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/18.e8063fee.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/19.068739ed.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/20.2b248747.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/21.4fd4cbc1.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/22.2683cc54.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/23.2e39bbe5.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/24.560a4164.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/25.26555323.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/26.8b7e1943.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/27.0f4ac9a1.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/28.f89ec4c0.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/29.71c751c3.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/30.ad576991.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/31.2746a45e.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/33.ae9d6c1c.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/34.53969cd0.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/35.3e1a8a01.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/36.eb74300d.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/37.16568451.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/38.9a3bc894.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/39.7aab5a75.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/4.c231685d.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/40.cd44603a.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/41.64d0c11a.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/42.3fb5d657.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/43.d4f19236.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/44.6abd5f31.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/45.eaf7b761.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/46.d891856e.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/5.0292b513.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/6.df2ba939.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/7.3b1acb14.js"><link rel="prefetch" href="/manor-farm-mysql/assets/js/9.5220a7da.js">
    <link rel="stylesheet" href="/manor-farm-mysql/assets/css/0.styles.7bfce8db.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-2d5f533b><div data-v-2d5f533b><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-2d5f533b data-v-2d5f533b><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-59a94c5a data-v-2d5f533b data-v-2d5f533b><h3 class="title" style="display:none;" data-v-59a94c5a data-v-59a94c5a>Manor Farm Mysql</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-59a94c5a data-v-59a94c5a><input type="password" value="" data-v-59a94c5a> <span data-v-59a94c5a>已加密!</span> <button data-v-59a94c5a>OK</button></label> <div class="footer" style="display:none;" data-v-59a94c5a data-v-59a94c5a><span data-v-59a94c5a><i class="iconfont reco-eye" data-v-59a94c5a></i> <a target="blank" href="https://pgmanor.gitee.io/blog/" data-v-59a94c5a>密钥</a></span> <span data-v-59a94c5a><i class="iconfont reco-theme" data-v-59a94c5a></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59a94c5a>vuePress-theme-reco</a></span> <span data-v-59a94c5a><i class="iconfont reco-copyright" data-v-59a94c5a></i> <a data-v-59a94c5a><span data-v-59a94c5a>pgmanor</span>
  
<!---->
2021
</a></span></div></div> <div class="hide" data-v-2d5f533b><header class="navbar" data-v-2d5f533b><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/manor-farm-mysql/" class="home-link router-link-active"><img src="/manor-farm-mysql/pgmanor_mysql.svg" alt="Manor Farm Mysql" class="logo"> <span class="site-name">Manor Farm Mysql</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/manor-farm-mysql/zh/guide/" class="nav-link router-link-active"><i class="iconfont reco-api"></i>
  指南
</a></div><div class="nav-item"><a href="/manor-farm-mysql/zh/fix/messageBoard.html" class="nav-link"><i class="iconfont reco-suggestion"></i>
  留言版
</a></div><div class="nav-item"><a href="https://pgmanor.gitee.io/blog/2021/01/10/secret-farm-mysql/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-eye"></i>
  文章密钥
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-qq"></i>
      联系
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>QQ在线</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://wpa.qq.com/msgrd?v=3&amp;uin=2307546059&amp;site=qq&amp;menu=yes" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  pgmanor
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他方式</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/manor-farm-mysql/zh/fix/contactUs.html" class="nav-link"><i class="iconfont undefined"></i>
  更多
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-other"></i>
      友链
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://pgmanor.gitee.io/blog/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  pgmanor
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.csdn.net/u011622109" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csd"></i>
  csdn
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://www.iworkh.com" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  iworkh
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>Vue</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://cn.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Vue
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://v1.vuepress.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  VuePress
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://vuepress-theme-reco.recoluan.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  vuepress-theme-reco
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="/manor-farm-mysql/zh/fix/donate.html" class="nav-link"><i class="iconfont reco-Coding"></i>
  捐赠
</a></div><div class="nav-item"><a href="https://gitee.com/pgmanor/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-2d5f533b></div> <aside class="sidebar" data-v-2d5f533b><div class="personal-info-wrapper" data-v-ca798c94 data-v-2d5f533b><img src="/manor-farm-mysql/pgmanor_mysql.svg" alt="author-avatar" class="personal-img" data-v-ca798c94> <h3 class="name" data-v-ca798c94>
    pgmanor
  </h3> <div class="num" data-v-ca798c94><div data-v-ca798c94><h3 data-v-ca798c94>30</h3> <h6 data-v-ca798c94>文章</h6></div> <div data-v-ca798c94><h3 data-v-ca798c94>26</h3> <h6 data-v-ca798c94>标签</h6></div></div> <hr data-v-ca798c94></div> <nav class="nav-links"><div class="nav-item"><a href="/manor-farm-mysql/zh/guide/" class="nav-link router-link-active"><i class="iconfont reco-api"></i>
  指南
</a></div><div class="nav-item"><a href="/manor-farm-mysql/zh/fix/messageBoard.html" class="nav-link"><i class="iconfont reco-suggestion"></i>
  留言版
</a></div><div class="nav-item"><a href="https://pgmanor.gitee.io/blog/2021/01/10/secret-farm-mysql/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-eye"></i>
  文章密钥
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-qq"></i>
      联系
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>QQ在线</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://wpa.qq.com/msgrd?v=3&amp;uin=2307546059&amp;site=qq&amp;menu=yes" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  pgmanor
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他方式</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/manor-farm-mysql/zh/fix/contactUs.html" class="nav-link"><i class="iconfont undefined"></i>
  更多
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-other"></i>
      友链
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://pgmanor.gitee.io/blog/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  pgmanor
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.csdn.net/u011622109" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csd"></i>
  csdn
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://www.iworkh.com" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  iworkh
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>Vue</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://cn.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Vue
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://v1.vuepress.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  VuePress
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://vuepress-theme-reco.recoluan.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  vuepress-theme-reco
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="/manor-farm-mysql/zh/fix/donate.html" class="nav-link"><i class="iconfont reco-Coding"></i>
  捐赠
</a></div><div class="nav-item"><a href="https://gitee.com/pgmanor/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>初入尘世</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/manor-farm-mysql/zh/guide/essentials/e-01-install.html" aria-current="page" class="active sidebar-link">安装</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-02-ddl-dcl.html" class="sidebar-link">DDL语句</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-03-dml.html" class="sidebar-link">DML语句</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-04-sort.html" class="sidebar-link">sort排序</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-05-group.html" class="sidebar-link">group分组</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-06-union.html" class="sidebar-link">union合并</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-07-join.html" class="sidebar-link">join</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-08-transaction.html" class="sidebar-link">事务</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-09-view.html" class="sidebar-link">视图</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-10-procedure.html" class="sidebar-link">存储过程</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-11-function.html" class="sidebar-link">函数</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-12-index.html" class="sidebar-link">索引</a></li><li><a href="/manor-farm-mysql/zh/guide/essentials/e-13-devops.html" class="sidebar-link">运维</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>千锤百炼</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/manor-farm-mysql/zh/guide/advanced/a-01-introduction.html" class="sidebar-link">本章介绍</a></li><li><a href="/manor-farm-mysql/zh/guide/advanced/a-02-prepare-data.html" class="sidebar-link">数据准备</a></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><a href="/manor-farm-mysql/zh/guide/" class="sidebar-heading clickable router-link-active"><span>原理</span> <span class="arrow right"></span></a> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><a href="/manor-farm-mysql/zh/guide/" class="sidebar-heading clickable router-link-active"><span>优化</span> <span class="arrow right"></span></a> <!----></section></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>百战成神</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-59a94c5a data-v-2d5f533b><h3 class="title" style="display:none;" data-v-59a94c5a data-v-59a94c5a>安装</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-59a94c5a data-v-59a94c5a><input type="password" value="" data-v-59a94c5a> <span data-v-59a94c5a>已加密!</span> <button data-v-59a94c5a>OK</button></label> <div class="footer" style="display:none;" data-v-59a94c5a data-v-59a94c5a><span data-v-59a94c5a><i class="iconfont reco-eye" data-v-59a94c5a></i> <a target="blank" href="https://pgmanor.gitee.io/blog/" data-v-59a94c5a>密钥</a></span> <span data-v-59a94c5a><i class="iconfont reco-theme" data-v-59a94c5a></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-59a94c5a>vuePress-theme-reco</a></span> <span data-v-59a94c5a><i class="iconfont reco-copyright" data-v-59a94c5a></i> <a data-v-59a94c5a><span data-v-59a94c5a>pgmanor</span>
  
<!---->
2021
</a></span></div></div> <div data-v-2d5f533b><main class="page"><div class="page-title" style="display:none;"><h1 class="title">安装</h1> <div data-v-3b7f5bdf><i class="iconfont reco-account" data-v-3b7f5bdf><span data-v-3b7f5bdf>pgmanor</span></i> <i class="iconfont reco-date" data-v-3b7f5bdf><span data-v-3b7f5bdf>2021-01-01</span></i> <i class="iconfont reco-eye" data-v-3b7f5bdf><span id="/manor-farm-mysql/zh/guide/essentials/e-01-install.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-3b7f5bdf><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-3b7f5bdf><span class="tag-item" data-v-3b7f5bdf>安装</span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><p>本文主要介绍下各个系统的安装</p> <div id="boxx" data-v-f4ca0dac><div data-v-f4ca0dac><p v-if="true" class="custom-block-title" data-v-f4ca0dac></p> <p v-if="true" data-v-f4ca0dac></p></div></div> <ul><li><a href="https://www.mysql.com/" target="_blank" rel="noopener noreferrer">mysql官网文档<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://dev.mysql.com/downloads/windows/installer/" target="_blank" rel="noopener noreferrer">mysql官方下载地址<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://dev.mysql.com/doc/refman/8.0/en/installing.html" target="_blank" rel="noopener noreferrer">myql官网安装教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <blockquote><p>最好查看官网安装教程，学会最新英文文档阅读</p></blockquote> <h2 id="_1-windows">1.windows</h2> <p>网上一堆教程，这就不浪费时间去整理了，自己利用网络资源安装下吧</p> <p><strong>主要有以下几种方式</strong></p> <ul><li>installer 傻瓜式下一步选择安装即可</li> <li>zip 通过解压，配置文件、初始化几个步骤安装</li></ul> <p><strong>供参考文章</strong></p> <ul><li><a href="https://pgmanor.gitee.io/blog/2020/12/31/blog-mysql-windows-zip-install/" target="_blank" rel="noopener noreferrer">mysql zip在windows上安装<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.runoob.com/w3cnote/windows10-mysql-installer.html" target="_blank" rel="noopener noreferrer">Windows10 MYSQL Installer<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <p><strong>my.ini配置文件</strong></p> <div class="language-ini line-numbers-mode"><pre class="language-ini"><code><span class="token selector">[client]</span>
<span class="token comment"># 设置mysql客户端连接服务端时默认使用的端口</span>
<span class="token constant">port</span><span class="token attr-value"><span class="token punctuation">=</span>3306</span>
<span class="token constant">default-character-set</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4</span>

<span class="token selector">[mysql]</span>
<span class="token comment"># 设置mysql客户端默认字符集</span>
<span class="token constant">default-character-set</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4</span>

<span class="token selector">[mysqld]</span>
<span class="token comment">#设置3306端口</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3306</span>
<span class="token comment">#设置mysql的安装目录</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>F:/db/mysql-8.0.21-winx64</span>
<span class="token comment">#设置 mysql数据库的数据的存放目录，MySQL 8+ 不需要以下配置，系统自己生成即可，否则有可能报错</span>
<span class="token constant">datadir</span><span class="token attr-value"><span class="token punctuation">=</span>F:/db/mysql-8.0.21-winx64/data</span>
<span class="token comment">#允许最大连接数</span>
<span class="token constant">max_connections</span><span class="token attr-value"><span class="token punctuation">=</span>200</span>
<span class="token comment"># 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统</span>
<span class="token constant">max_connect_errors</span><span class="token attr-value"><span class="token punctuation">=</span>10</span>
<span class="token comment">#服务端使用的字符集默认为8比特编码的latin1字符集</span>
<span class="token constant">character-set-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4</span>
<span class="token comment"># 数据库字符集对应一些排序等规则使用的字符集</span>
<span class="token constant">collation-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4_general_ci</span>
<span class="token comment"># 认证方式</span>
<span class="token constant">default_authentication_plugin</span><span class="token attr-value"><span class="token punctuation">=</span>mysql_native_password</span>
<span class="token comment"># 时区</span>
<span class="token constant">default-time-zone</span><span class="token attr-value"><span class="token punctuation">=</span>'+08:00'</span>
<span class="token comment">#创建新表时将使用的默认存储引擎</span>
<span class="token constant">default-storage-engine</span><span class="token attr-value"><span class="token punctuation">=</span>INNODB</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>basedir和datadir: 路径用/，不然像\s,\t等，会跟\在一起组合的字符会被转移了</p></div> <h2 id="_2-linux">2.linux</h2> <p><strong>主要有以下几种方式</strong></p> <ul><li>tar.gz 通过解压，配置文件、初始化几个步骤安装</li> <li>在线安装</li></ul> <p><strong>供参考文章</strong></p> <ul><li><a href="https://blog.csdn.net/github_39533414/article/details/80144890" target="_blank" rel="noopener noreferrer">tar.gz方式--Linux安装MySQL8.0.11<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://blog.csdn.net/weixin_41087914/article/details/108384196" target="_blank" rel="noopener noreferrer">linux mysql 离线安装<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://blog.csdn.net/xyang81/article/details/51759200" target="_blank" rel="noopener noreferrer">yum--linux上mysql安装<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.nonelonely.com/article/1544510837589" target="_blank" rel="noopener noreferrer">Linux(Centos)在线安装MySql<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <p><strong>/etc/my.cnf,/etc/mysql/my.cnf配置文件</strong></p> <div class="language-ini line-numbers-mode"><pre class="language-ini"><code><span class="token selector">[client]</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3306</span>
<span class="token constant">socket</span> <span class="token attr-value"><span class="token punctuation">=</span> /var/lib/mysql/mysql.sock</span>
<span class="token constant">default-character-set</span> <span class="token attr-value"><span class="token punctuation">=</span> utf8</span>

<span class="token selector">[mysql]</span>
no-auto-rehash          #仅允许使用键值的updates和deletes

<span class="token selector">[mysqldump]</span>
quick
<span class="token constant">max_allowed_packet</span> <span class="token attr-value"><span class="token punctuation">=</span> 64M</span>

<span class="token selector">[mysqld]</span>
<span class="token constant">basedir</span> <span class="token attr-value"><span class="token punctuation">=</span> /usr/local/mysql</span>
<span class="token constant">datadir</span> <span class="token attr-value"><span class="token punctuation">=</span> /var/lib/mysql</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3306</span>
<span class="token constant">socket</span> <span class="token attr-value"><span class="token punctuation">=</span> /var/lib/mysql/mysql.sock</span>

<span class="token constant">server-id</span> <span class="token attr-value"><span class="token punctuation">=</span> 1</span>
<span class="token constant">log-bin</span> <span class="token attr-value"><span class="token punctuation">=</span> /data/mysql/binlog/mysql-bin</span>
<span class="token constant">relay-log</span> <span class="token attr-value"><span class="token punctuation">=</span> /data/mysql/binlog/mysql-relay-bin</span>
<span class="token constant">binlog-cache-size</span> <span class="token attr-value"><span class="token punctuation">=</span> 4M          #设置二进制日志缓存大小</span>
<span class="token constant">max_binlog_cache_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 8M      #最大的二进制Cache日志缓冲尺寸</span>
<span class="token constant">max_binlog_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 1G            #单个二进制日志文件的最大值，默认1G，最大1G</span>
<span class="token constant">sync-binlog</span> <span class="token attr-value"><span class="token punctuation">=</span> 1                 #每隔N秒将缓存中的二进制日志记录写回硬盘</span>
<span class="token constant">binlog_format</span> <span class="token attr-value"><span class="token punctuation">=</span> mixed          #二进制日志格式（mixed、row、statement）</span>
<span class="token comment">#log_slave_updates = 1          #从服务器从主服务器收到的更新记入到从服务器自己的二进制日志文件中</span>
<span class="token constant">expire_logs_days</span> <span class="token attr-value"><span class="token punctuation">=</span> 30           #二进制日志文件过期时间</span>
<span class="token constant">replicate-wild-do-table</span><span class="token attr-value"><span class="token punctuation">=</span>testdb1.%</span>
<span class="token constant">replicate-wild-do-table</span><span class="token attr-value"><span class="token punctuation">=</span>testdb2.%</span>
<span class="token constant">replicate-wild-do-table</span><span class="token attr-value"><span class="token punctuation">=</span>testdb3.%</span>

<span class="token constant">log-error</span> <span class="token attr-value"><span class="token punctuation">=</span> /data/mysql/log/mysql_error.log     #错误日志文件路径</span>
<span class="token constant">back_log</span> <span class="token attr-value"><span class="token punctuation">=</span> 384                  #指出在MySQL暂时停止响应新请求之前，短时间内的多少个请求</span>
<span class="token constant">character-set-server</span> <span class="token attr-value"><span class="token punctuation">=</span> utf8     #默认字符集</span>
<span class="token constant">external-locking</span> <span class="token attr-value"><span class="token punctuation">=</span> FALSE        #避免外部锁定(减少出错几率，增加稳定性)</span>
skip-name-resolv                #禁止外部连接进行DNS解析
<span class="token constant">thread_concurrency</span> <span class="token attr-value"><span class="token punctuation">=</span> 32         #CPU核数的两倍</span>
<span class="token constant">default-storage-engine</span><span class="token attr-value"><span class="token punctuation">=</span>InnoDB   #默认表的类型为InnoDB</span>
<span class="token constant">transaction_isolation</span> <span class="token attr-value"><span class="token punctuation">=</span> READ-COMMITTED  #事务隔离级别</span>

<span class="token constant">open_files_limit</span> <span class="token attr-value"><span class="token punctuation">=</span> 65535        #Mysql能打开文件的最大个数</span>
<span class="token constant">max_connections</span> <span class="token attr-value"><span class="token punctuation">=</span> 5000          #指定MySQL允许的最大连接进程数</span>
<span class="token constant">max_connect_errors</span> <span class="token attr-value"><span class="token punctuation">=</span> 6000       #设置每个主机的连接请求异常中断的最大次数</span>
<span class="token constant">max_allowed_packet</span> <span class="token attr-value"><span class="token punctuation">=</span> 16M        #服务器一次能处理的最大的查询包的值</span>
<span class="token constant">wait_timeout</span> <span class="token attr-value"><span class="token punctuation">=</span> 120              #指定一个请求的最大连接时间</span>
<span class="token constant">interactive_timeout</span> <span class="token attr-value"><span class="token punctuation">=</span> 8         #连接保持活动的时间</span>
<span class="token constant">thread_stack</span> <span class="token attr-value"><span class="token punctuation">=</span> 192K             #设置Mysql每个线程的堆栈大小，默认值足够大，可满足普通操作</span>

<span class="token constant">long_query_time</span> <span class="token attr-value"><span class="token punctuation">=</span> 2             #指定多少秒未返回结果的查询属于慢查询</span>
<span class="token comment">#slow_query_log = on            #开启慢查询</span>
<span class="token comment">#slow_query_log_file = /data/mysql/slow.log     #指定慢查询日志文件路径</span>
<span class="token comment">#log-queries-not-using-indexes  #记录所有没有使用到索引的查询语句</span>
<span class="token comment">#min_examined_row_limit = 1000  #记录那些由于查找了多余1000次而引发的慢查询</span>
<span class="token comment">#log-slow-admin-statements      #记录那些慢的OPTIMIZE TABLE,ANALYZE TABLE和ALTER TABLE语句</span>
<span class="token comment">#log-slow-slave-statements      #记录由slave所产生的慢查询</span>

<span class="token constant">table_open_cache</span> <span class="token attr-value"><span class="token punctuation">=</span> 512          #设置高速缓存表的数目</span>
<span class="token constant">tmp_table_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 64M            #设置内存临时表最大值</span>
<span class="token constant">max_heap_table_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 64M       #独立的内存表所允许的最大容量</span>
<span class="token constant">thread_cache_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 64          #服务器线程缓存数，与内存大小有关(建议大于3G设置为64)</span>
<span class="token comment">#query_cache_size = 32M          #指定MySQL查询缓冲区的大小</span>
<span class="token constant">query_cache_limit</span> <span class="token attr-value"><span class="token punctuation">=</span> 2M          #只有小于此设置值的结果才会被缓存</span>
<span class="token constant">query_cache_min_res_unit</span> <span class="token attr-value"><span class="token punctuation">=</span> 2k   #设置查询缓存分配内存的最小单位</span>

<span class="token constant">key_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 32M           #指定用于索引的缓冲区大小，增加它可得到更好的索引处理性能</span>
<span class="token constant">sort_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 2M           #设置查询排序时所能使用的缓冲区大小，系统默认大小为2MB</span>
<span class="token constant">join_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 2M           #联合查询操作所能使用的缓冲区大小</span>
<span class="token constant">read_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 4M           #读查询操作所能使用的缓冲区大小</span>
<span class="token constant">read_rnd_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 16M      #设置进行随机读的时候所使用的缓冲区</span>
<span class="token constant">bulk_insert_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 8M    #若经常使用批量插入的特殊语句来插入数据，可以适当调整参数至16MB~32MB，建议8MB</span>

<span class="token constant">myisam_sort_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 64M</span>
<span class="token constant">myisam_max_sort_file_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 10G</span>
<span class="token constant">myisam_repair_threads</span> <span class="token attr-value"><span class="token punctuation">=</span> 1</span>
myisam_recover                  #自动检查和修复没有适当关闭的MyISAM表

<span class="token constant">innodb_additional_mem_pool_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 16M   #设置InnoDB存储的数据目录信息和其他内部数据结构的内存池大小</span>
<span class="token constant">innodb_buffer_pool_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 128M          #InnoDB使用一个缓冲池来保存索引和原始数据</span>
<span class="token constant">innodb_file_io_threads</span> <span class="token attr-value"><span class="token punctuation">=</span> 4              #InnoDB中的文件I/O线程，通常设置为4</span>
<span class="token constant">innodb_thread_concurrency</span> <span class="token attr-value"><span class="token punctuation">=</span> 8           #服务器有几个CPU就设置为几，建议用默认设置，一般设为8</span>
<span class="token constant">innodb_flush_log_at_trx_commit</span> <span class="token attr-value"><span class="token punctuation">=</span> 2      #设置为0就等于innodb_log_buffer_size队列满后再统一存储，默认为1</span>
<span class="token constant">innodb_log_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 16M    #默认为1MB，通常设置为6-8MB就足够</span>
<span class="token constant">innodb_log_file_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 128M     #确定日志文件的大小，更大的设置可以提高性能，但也会增加恢复数据库的时间</span>
<span class="token constant">innodb_log_files_in_group</span> <span class="token attr-value"><span class="token punctuation">=</span> 3   #为提高性能，MySQL可以以循环方式将日志文件写到多个文件。推荐设置为3</span>
<span class="token constant">innodb_max_dirty_pages_pct</span> <span class="token attr-value"><span class="token punctuation">=</span> 90 #InnoDB主线程刷新缓存池中的数据</span>
<span class="token constant">innodb_lock_wait_timeout</span> <span class="token attr-value"><span class="token punctuation">=</span> 120  #InnoDB事务被回滚之前可以等待一个锁定的超时秒数</span>
<span class="token constant">innodb_file_per_table</span> <span class="token attr-value"><span class="token punctuation">=</span> 0       #InnoDB为独立表空间模式，每个数据库的每个表都会生成一个数据空间,0关闭,1开启</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br></div></div><p><strong>具体每项含义可以参照</strong></p> <ul><li><a href="https://blog.csdn.net/weixin_44666068/article/details/104829616" target="_blank" rel="noopener noreferrer">MySQL配置文件详解<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.cnblogs.com/wajika/p/6323026.html" target="_blank" rel="noopener noreferrer">my.cnf 详细解释<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h2 id="_3-login">3.login</h2> <p><strong>linux下mysql启动登陆命令</strong></p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>
<span class="token comment"># 启动</span>
<span class="token function">service</span> mysqld start

<span class="token comment"># 关闭</span>
<span class="token function">service</span> mysqld stop

<span class="token comment"># 状态</span>
<span class="token function">service</span> mysqld status

<span class="token comment"># 登陆</span>
mysql -u root -p
<span class="token comment"># 输入密码</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><h2 id="_4-ui工具">4.UI工具</h2> <ul><li>mysql自带的命令行工具</li> <li>图形UI工具
<ul><li><a href="https://dbeaver.com/" target="_blank" rel="noopener noreferrer">dbeaver<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://sqlyog.en.softonic.com/?ex=BB-1549.0" target="_blank" rel="noopener noreferrer">SQLyog<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.navicat.com.cn/products/navicat-for-mysql" target="_blank" rel="noopener noreferrer">navicat-for-mysql<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul> <blockquote><p>这些都用过，个人比较推荐<code>dbeaver</code>，因为它不仅仅支持Mysql，还支持其他数据库，它分开源和企业版。</p></blockquote> <p>具体如何使用工具，就不多介绍了。</p> <ul><li><a href="https://dbeaver.com/docs/wiki/" target="_blank" rel="noopener noreferrer">dbeaver官网wiki<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.freesion.com/article/9569131701/" target="_blank" rel="noopener noreferrer">MYSQL在DBEAVER上的使用<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h2 id="_5-数据类型">5.数据类型</h2> <p>MySQL支持的主要数据类型有：数值、日期/时间和字符串(字符)类型。</p> <h3 id="_5-1-数值">5-1.数值</h3> <p>整数： TINYINT、SMALLINT、MEDIUMINT、INT、BIGINT
小数： FLOAT、DOUBLE、DECIMAL</p> <table><thead><tr><th style="text-align:left;">类型</th> <th style="text-align:left;">大小</th> <th style="text-align:left;">范围（有符号）</th> <th style="text-align:left;">范围（无符号）</th> <th style="text-align:left;">用途</th></tr></thead> <tbody><tr><td style="text-align:left;">TINYINT</td> <td style="text-align:left;">1 byte</td> <td style="text-align:left;">(-128，127)</td> <td style="text-align:left;">(0，255)</td> <td style="text-align:left;">小整数值</td></tr> <tr><td style="text-align:left;">SMALLINT</td> <td style="text-align:left;">2 bytes</td> <td style="text-align:left;">(-32 768，32 767)</td> <td style="text-align:left;">(0，65 535)</td> <td style="text-align:left;">大整数值</td></tr> <tr><td style="text-align:left;">MEDIUMINT</td> <td style="text-align:left;">3 bytes</td> <td style="text-align:left;">(-8 388 608，8 388 607)</td> <td style="text-align:left;">(0，16 777 215)</td> <td style="text-align:left;">大整数值</td></tr> <tr><td style="text-align:left;">INT或INTEGER</td> <td style="text-align:left;">4 bytes</td> <td style="text-align:left;">(-2 147 483 648，2 147 483 647)</td> <td style="text-align:left;">(0，4 294 967 295)</td> <td style="text-align:left;">大整数值</td></tr> <tr><td style="text-align:left;">BIGINT</td> <td style="text-align:left;">8 bytes</td> <td style="text-align:left;">(-9,223,372,036,854,775,808，9 223 372 036 854 775 807)</td> <td style="text-align:left;">(0，18 446 744 073 709 551 615)</td> <td style="text-align:left;">极大整数值</td></tr> <tr><td style="text-align:left;">FLOAT</td> <td style="text-align:left;">4 bytes</td> <td style="text-align:left;">(-3.402 823 466 E+38，-1.175 494 351 E-38)，0，(1.175 494 351 E-38，3.402 823 466 351 E+38)</td> <td style="text-align:left;">0，(1.175 494 351 E-38，3.402 823 466 E+38)</td> <td style="text-align:left;">单精度 浮点数值</td></tr> <tr><td style="text-align:left;">DOUBLE</td> <td style="text-align:left;">8 bytes</td> <td style="text-align:left;">(-1.797 693 134 862 315 7 E+308，-2.225 073 858 507 201 4 E-308)，0，(2.225 073 858 507 201 4 E-308，1.797 693 134 862 315 7 E+308)</td> <td style="text-align:left;">0，(2.225 073 858 507 201 4 E-308，1.797 693 134 862 315 7 E+308)</td> <td style="text-align:left;">双精度 浮点数值</td></tr> <tr><td style="text-align:left;">DECIMAL</td> <td style="text-align:left;">对DECIMAL(M,D) ，如果M&gt;D，为M+2否则为D+2</td> <td style="text-align:left;">依赖于M和D的值</td> <td style="text-align:left;">依赖于M和D的值</td> <td style="text-align:left;">小数值</td></tr></tbody></table> <h3 id="_5-2-日期">5-2.日期</h3> <p>日期和时间类型：DATETIME、DATE、TIMESTAMP、TIME和YEAR。</p> <blockquote><p>工作中，我们经常使用的是DATETIME</p></blockquote> <table><thead><tr><th style="text-align:left;">类型</th> <th style="text-align:left;">大小 ( bytes)</th> <th style="text-align:left;">范围</th> <th style="text-align:left;">格式</th> <th style="text-align:left;">用途</th></tr></thead> <tbody><tr><td style="text-align:left;">DATE</td> <td style="text-align:left;">3</td> <td style="text-align:left;">1000-01-01/9999-12-31</td> <td style="text-align:left;">YYYY-MM-DD</td> <td style="text-align:left;">日期值</td></tr> <tr><td style="text-align:left;">TIME</td> <td style="text-align:left;">3</td> <td style="text-align:left;">'-838:59:59'/'838:59:59'</td> <td style="text-align:left;">HH:MM:SS</td> <td style="text-align:left;">时间值或持续时间</td></tr> <tr><td style="text-align:left;">YEAR</td> <td style="text-align:left;">1</td> <td style="text-align:left;">1901/2155</td> <td style="text-align:left;">YYYY</td> <td style="text-align:left;">年份值</td></tr> <tr><td style="text-align:left;">DATETIME</td> <td style="text-align:left;">8</td> <td style="text-align:left;">1000-01-01 00:00:00/9999-12-31 23:59:59</td> <td style="text-align:left;">YYYY-MM-DD HH:MM:SS</td> <td style="text-align:left;">混合日期和时间值</td></tr> <tr><td style="text-align:left;">TIMESTAMP</td> <td style="text-align:left;">4</td> <td style="text-align:left;">1970-01-01 00:00:00/2038结束时间是第 <strong>2147483647</strong> 秒，北京时间 <strong>2038-1-19 11:14:07</strong>，格林尼治时间 2038年1月19日 凌晨 03:14:07</td> <td style="text-align:left;">YYYYMMDD HHMMSS</td> <td style="text-align:left;">混合日期和时间值，时间戳</td></tr></tbody></table> <h3 id="_5-3-字符串">5-3.字符串</h3> <table><thead><tr><th style="text-align:left;">类型</th> <th style="text-align:left;">大小</th> <th style="text-align:left;">用途</th> <th>需要存储大小</th></tr></thead> <tbody><tr><td style="text-align:left;">CHAR(M)</td> <td style="text-align:left;">0-255 bytes</td> <td style="text-align:left;">定长字符串</td> <td>M 字节，1&lt;=M&lt;=255</td></tr> <tr><td style="text-align:left;">VARCHAR(M)</td> <td style="text-align:left;">0-65535 bytes</td> <td style="text-align:left;">变长字符串</td> <td>L+1字节，(L&lt; = M和 1&lt;=M&lt;=255)</td></tr> <tr><td style="text-align:left;">TINYBLOB</td> <td style="text-align:left;">0-255 bytes</td> <td style="text-align:left;">不超过 255 个字符的二进制字符串</td> <td>L+1字节，在此，L&lt;2^8</td></tr> <tr><td style="text-align:left;">TINYTEXT</td> <td style="text-align:left;">0-255 bytes</td> <td style="text-align:left;">短文本字符串</td> <td>L+1字节，在此，L&lt;2^8</td></tr> <tr><td style="text-align:left;">BLOB</td> <td style="text-align:left;">0-65 535 bytes</td> <td style="text-align:left;">二进制形式的长文本数据</td> <td>L+2 字节，在此，L&lt;2^16</td></tr> <tr><td style="text-align:left;">TEXT</td> <td style="text-align:left;">0-65 535 bytes</td> <td style="text-align:left;">长文本数据</td> <td>L+2字节，在此，L&lt;2^16</td></tr> <tr><td style="text-align:left;">MEDIUMBLOB</td> <td style="text-align:left;">0-16 777 215 bytes</td> <td style="text-align:left;">二进制形式的中等长度文本数据</td> <td>L+3 字节，在此，L&lt;2^24</td></tr> <tr><td style="text-align:left;">MEDIUMTEXT</td> <td style="text-align:left;">0-16 777 215 bytes</td> <td style="text-align:left;">中等长度文本数据</td> <td>L+3字节，在此，L&lt;2^24</td></tr> <tr><td style="text-align:left;">LONGBLOB</td> <td style="text-align:left;">0-4 294 967 295 bytes</td> <td style="text-align:left;">二进制形式的极大文本数据</td> <td>L+4 字节，在此，L&lt;2^32</td></tr> <tr><td style="text-align:left;">LONGTEXT</td> <td style="text-align:left;">0-4 294 967 295 bytes</td> <td style="text-align:left;">极大文本数据</td> <td>L+4字节，在此，L&lt;2^32</td></tr></tbody></table> <p>CHAR和VARCHAR的区别</p> <ul><li>CHAR(M) 为固定长度字符串，在定义时指定字符串列长。当保存时，在右侧填充空格以达到指定的长度。M 表示列的长度，范围是 0～255 个字符。</li> <li>VARCHAR(M) 是长度可变的字符串，M 表示最大列的长度，M 的范围是 0～65535。VARCHAR 的最大实际长度由最长的行的大小和使用的字符集确定，实际占用的空间为字符串的实际长度+1。</li></ul> <p><strong>示例</strong></p> <table><thead><tr><th>插入值</th> <th>CHAR(4)</th> <th>存储需求</th> <th>VARCHAR(4)</th> <th>存储需求</th></tr></thead> <tbody><tr><td>' '</td> <td>'  '</td> <td>4字节</td> <td>''</td> <td>1字节</td></tr> <tr><td>'ab'</td> <td>'ab '</td> <td>4字节</td> <td>'ab'</td> <td>3字节</td></tr> <tr><td>'abc'</td> <td>'abc '</td> <td>4字节</td> <td>'abc'</td> <td>4字节</td></tr> <tr><td>'abcd'</td> <td>'abcd'</td> <td>4字节</td> <td>'abcd'</td> <td>5字节</td></tr> <tr><td>'abcdef'</td> <td>'abcd'</td> <td>4字节</td> <td>'abcd'</td> <td>5字节</td></tr></tbody></table> <blockquote><p>CHAR的值一直是固定的，不足就补0；大于M的话，存储不下，只能存4直接。
VARCHAR的值不是固定的，最大为M+1</p></blockquote></div> <footer class="page-edit" style="display:none;"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2020-12-18 6:27:50 PM</span></div></footer> <!----> <!----> <!----></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><!----><!----><APlayer audio="" fixed="true" mini="true" theme="#f9bcdd" loop="loop" order="random" preload="auto" volume="0.1" mutex="true" lrc-type="0" list-folded="true" list-max-height="250" storage-name="vuepress-plugin-meting" id="aplayer-fixed"></APlayer></div></div>
    <script src="/manor-farm-mysql/assets/js/app.bbd54b43.js" defer></script><script src="/manor-farm-mysql/assets/js/3.33fa8ee0.js" defer></script><script src="/manor-farm-mysql/assets/js/1.e501e4e7.js" defer></script><script src="/manor-farm-mysql/assets/js/32.b62e21d8.js" defer></script><script src="/manor-farm-mysql/assets/js/8.73e907b5.js" defer></script>
  </body>
</html>
